Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
stylelint-order
Advanced tools
The stylelint-order npm package is a plugin for stylelint that provides order related linting rules for CSS properties within declaration blocks. It helps in enforcing a consistent order for CSS properties, which can make code easier to read and maintain.
Specifying the order of content within declaration blocks
This feature allows you to define the order in which different types of content within a declaration block should appear. For example, you can specify that custom properties should be declared before any other declarations.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/order": [
"custom-properties",
"declarations"
],
"order/properties-order": [
"position",
"top",
"right",
"bottom",
"left"
]
}
}
Specifying the order of properties within declaration blocks
This feature allows you to define a specific order for CSS properties within a declaration block. You can list the properties in the order you want them to be linted. This can be a custom order or alphabetical order.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/properties-order": [
"position",
"z-index",
"top",
"right",
"bottom",
"left"
],
"order/properties-alphabetical-order": {}
}
}
Grouping and separating properties
This feature allows you to group related properties together and enforce an empty line before the group or between groups. This can improve readability and organization of CSS rules.
{
"plugins": [
"stylelint-order"
],
"rules": {
"order/properties-order": [
[
"position",
"z-index"
],
{
"emptyLineBefore": "always",
"properties": [
"color",
"font-size",
"font-weight"
]
}
]
}
}
CSScomb is a coding style formatter for CSS. Similar to stylelint-order, it can sort CSS properties in a specific order. However, CSScomb is not a plugin for stylelint and has its own configuration and usage patterns.
postcss-sorting is a PostCSS plugin that sorts CSS properties according to specified order. It is similar to stylelint-order in functionality but is used within the PostCSS ecosystem, which is a tool for transforming CSS with JavaScript plugins.
sass-lint is a tool to help you enforce consistent conventions and avoid errors in your stylesheets. It is similar to stylelint-order in that it can enforce property order, but it is specifically designed for linting Sass files, not standard CSS.
A plugin pack of order related linting rules for stylelint. Every rule support autofixing (stylelint --fix
).
First, install stylelint:
npm install stylelint --save-dev
Then install plugin:
npm install stylelint-order --save-dev
Add stylelint-order
to your stylelint config plugins array, then add rules you need to the rules list. All rules from stylelint-order need to be namespaced with order
.
Like so:
// .stylelintrc
{
"plugins": [
"stylelint-order"
],
"rules": {
// ...
"order/order": [
"custom-properties",
"declarations"
],
"order/properties-alphabetical-order": true
// ...
}
}
order
: Specify the order of content within declaration blocks.properties-order
: Specify the order of properties within declaration blocks.properties-alphabetical-order
: Specify the alphabetical order of properties within declaration blocks.Every rule support autofixing (stylelint --fix
). postcss-sorting is using internally for order autofixing.
Automatic sortings has some limitation, which are described for every rule if any. Please, take a look at how comments are handled by postcss-sorting.
Autofixing is enabled by default if it's enabled in stylelint configuration. Autofixing can be disabled on per rule basis using disableFix: true
secondary option. E. g.:
{
"rules": {
"order/order": [
[
"custom-properties",
"declarations"
],
{
"disableFix": true
}
]
}
}
Less isn't supported. It might work, but haven't tested.
properties-order
and properties-alphabetical-order
code and readme are based on declaration-block-properties-order
rule which was a stylelint's core rule prior stylelint 8.0.0.
FAQs
A collection of order related linting rules for Stylelint.
We found that stylelint-order demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.